import axios from './config.js'

export default {

    login({username, password}){
        // loading: true, 显示加载动画
        return axios.post('/api/token', {username, password}, {loading: true, permission: false})
    },
    getAccessToken(refreshToken){
        return axios.post('/api/token/refresh', {refresh: refreshToken},{
            headers: {
                'Content-Type': "application/x-www-form-urlencoded"
            },
            permission: false
        })
    },

    saveUser({username, password, name, tel, is_active, clazz, role}){
        return axios.post('/user/user', {username, password, name, tel, is_active, clazz, role, is_staff: true}, {
            loading: true, permission: true
        })
    },
    getRoleAndClazzList(){
        return axios.get('/user/user/find-role-clazz-list', {permission: true})
    },
    getUserList(page, rows){
        return axios.get('/user/user', {
            params: {page, rows},
            loading: true, 
            permission: true
        })
    }
    
}